// 预约管理相关 API
import request from '@/utils/request';

import { ApiResponse, PageParams, PageResult } from '@/types/common';
import { ReservationInfo, ReservationForm } from '@/types/reservation';

export const reservationApi = {
  // 获取预约列表
  getReservations: (params: PageParams): Promise<ApiResponse<PageResult<ReservationInfo>>> =>
    request.get('/reservations', params),

  // 获取预约详情
  getReservation: (id: string): Promise<ApiResponse<ReservationInfo>> =>
    request.get(`/reservations/${id}`),

  // 创建预约
  createReservation: (data: ReservationForm): Promise<ApiResponse<ReservationInfo>> =>
    request.post('/reservations', data),

  // 更新预约
  updateReservation: (id: string, data: Partial<ReservationForm>): Promise<ApiResponse<ReservationInfo>> =>
    request.put(`/reservations/${id}`, data),

  // 删除预约
  deleteReservation: (id: string): Promise<ApiResponse<void>> =>
    request.delete(`/reservations/${id}`),

  // 审核预约
  approveReservation: (id: string, approved: boolean, reason?: string): Promise<ApiResponse<void>> =>
    request.post(`/reservations/${id}/approve`, { approved, reason }),

  // 取消预约
  cancelReservation: (id: string, reason?: string): Promise<ApiResponse<void>> =>
    request.post(`/reservations/${id}/cancel`, { reason }),
}; 